home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / ipport / peekwww.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-15  |  5.1 KB  |  183 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "WWW Peek..."
  5.    ClientHeight    =   6090
  6.    ClientLeft      =   1455
  7.    ClientTop       =   2520
  8.    ClientWidth     =   6405
  9.    Height          =   6495
  10.    Left            =   1395
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   6090
  13.    ScaleWidth      =   6405
  14.    Top             =   2175
  15.    Width           =   6525
  16.    Begin TextBox tResponse 
  17.       Height          =   4095
  18.       Left            =   0
  19.       MultiLine       =   -1  'True
  20.       ScrollBars      =   3  'Both
  21.       TabIndex        =   5
  22.       Top             =   2040
  23.       Width           =   6375
  24.    End
  25.    Begin CommandButton Command1 
  26.       Caption         =   "Send HTTP Request..."
  27.       Height          =   375
  28.       Left            =   3240
  29.       TabIndex        =   4
  30.       Top             =   1560
  31.       Width           =   2295
  32.    End
  33.    Begin TextBox tURLPath 
  34.       Height          =   285
  35.       Left            =   1440
  36.       TabIndex        =   3
  37.       Text            =   "/"
  38.       Top             =   1080
  39.       Width           =   4095
  40.    End
  41.    Begin TextBox tHostAddress 
  42.       Height          =   285
  43.       Left            =   2280
  44.       TabIndex        =   2
  45.       Top             =   600
  46.       Width           =   2535
  47.    End
  48.    Begin TextBox tHostName 
  49.       Height          =   285
  50.       Left            =   2280
  51.       TabIndex        =   1
  52.       Text            =   "www.ncsu.edu"
  53.       Top             =   240
  54.       Width           =   2535
  55.    End
  56.    Begin IPPORT IPPort1 
  57.       EOL             =   ""
  58.       InBufferSize    =   2048
  59.       Left            =   5040
  60.       LocalPort       =   0
  61.       OutBufferSize   =   2048
  62.       Port            =   0
  63.       Top             =   240
  64.    End
  65.    Begin Label Label1 
  66.       BackStyle       =   0  'Transparent
  67.       Caption         =   "Server Response:"
  68.       Height          =   255
  69.       Index           =   3
  70.       Left            =   120
  71.       TabIndex        =   8
  72.       Top             =   1680
  73.       Width           =   2415
  74.    End
  75.    Begin Label Label1 
  76.       BackStyle       =   0  'Transparent
  77.       Caption         =   "URL Path:"
  78.       Height          =   255
  79.       Index           =   2
  80.       Left            =   120
  81.       TabIndex        =   7
  82.       Top             =   1110
  83.       Width           =   1095
  84.    End
  85.    Begin Label Label1 
  86.       BackStyle       =   0  'Transparent
  87.       Caption         =   "Remote Host Address:"
  88.       Height          =   255
  89.       Index           =   1
  90.       Left            =   120
  91.       TabIndex        =   6
  92.       Top             =   630
  93.       Width           =   2175
  94.    End
  95.    Begin Label Label1 
  96.       BackStyle       =   0  'Transparent
  97.       Caption         =   "Remote Host Name:"
  98.       Height          =   255
  99.       Index           =   0
  100.       Left            =   120
  101.       TabIndex        =   0
  102.       Top             =   270
  103.       Width           =   1815
  104.    End
  105. Sub Command1_Click ()
  106. On Error GoTo ErrorHandling:
  107. IPPort1.EOL = Chr$(10)
  108. Me.MousePointer = 11
  109. 'close old connection - if any
  110. IPPort1.Connected = False
  111. If IPPort1.HostAddress = "0.0.0.0" Then
  112.     If tHostName <> "" Then
  113.         IPPort1.HostName = tHostName.Text
  114.         tHostAddress.Text = IPPort1.HostAddress
  115.     ElseIf IPPort1.HostAddress <> "" Then
  116.         IPPort1.HostAddress = tHostAddress.Text
  117.         tHostName.Text = IPPort1.HostName
  118.     Else
  119.         MsgBox "Please specify a host."
  120.         Exit Sub
  121.     End If
  122. End If
  123. IPPort1.Port = 80
  124. 'ask for connection
  125. IPPort1.Connected = True
  126. 'wait until it is achieved
  127. Do Until IPPort1.Connected: DoEvents: Loop
  128. 'send data
  129. IPPort1.DataToSend = "GET " & tURLPath.Text & Chr$(10)
  130. Exit Sub
  131. ErrorHandling:
  132.     Me.MousePointer = 0
  133.     MsgBox "Error!! " & Error$
  134.     IPPort1.Connected = False
  135.     Exit Sub
  136. End Sub
  137. Sub Form_Resize ()
  138. tResponse.Height = Me.ScaleHeight - tResponse.Top
  139. tResponse.Width = Me.ScaleWidth
  140. End Sub
  141. Sub IPPort1_Connected (StatusCode As Integer, Description As String)
  142. tResponse = ""
  143. If Description <> "OK" Then
  144.     MsgBox "Connection error: " & Description
  145.     Me.MousePointer = 0
  146. End If
  147. End Sub
  148. Sub IPPort1_DataIn (Text As String, EOL As Integer)
  149. If EOL Then Text = Text & Chr$(13) & Chr$(10)
  150. tResponse.SelStart = Len(tResponse.Text)
  151. tResponse.SelText = Text
  152. End Sub
  153. Sub IPPort1_Disconnected (StatusCode As Integer, Description As String)
  154. Me.MousePointer = 0
  155. If Description <> "OK" Then
  156.     MsgBox "Connection broken: " & Description
  157. End If
  158. End Sub
  159. Sub tHostAddress_KeyPress (KeyAscii As Integer)
  160. On Error GoTo DAR_Failed:
  161. If KeyAscii = 13 Then
  162.     KeyAscii = 0
  163.     IPPort1.HostAddress = tHostAddress.Text
  164.     tHostName.Text = IPPort1.HostName
  165. End If
  166. Exit Sub
  167. DAR_Failed:
  168.     MsgBox Error$
  169.     Exit Sub
  170. End Sub
  171. Sub tHostName_KeyPress (KeyAscii As Integer)
  172. On Error GoTo DNR_Failed:
  173. If KeyAscii = 13 Then
  174.     KeyAscii = 0
  175.     IPPort1.HostName = tHostName.Text
  176.     tHostAddress.Text = IPPort1.HostAddress
  177. End If
  178. Exit Sub
  179. DNR_Failed:
  180.     MsgBox Error$
  181.     Exit Sub
  182. End Sub
  183.